<?php
//ini_set('display_errors', 'On');
class Express extends BaseDB
{
	function __construct(){
		$this->table = 'express';
		parent::__construct();
	}
	
	public function add($data){
		if (empty($data['name']) || empty($data['tel']))return false;
		return $this->insert(array(
			'name'=>$data['name'],
			'tel'=>$data['tel'],
			'remark'=>$data['remark'],
			'update_time'=>date("Y-m-d H:i:s")));
	}
	
	public function delById($id){
		if (empty($id)) return false;
		return $this->delete(array('id'=>$id));
	}
	
	public function modify($data, $where) {
		if (empty($data) || !is_array($data))return false;
		$data['update_time'] = date("Y-m-d H:i:s");
		return $this->update($data, $where);
	}
	
	public function getList($start = 0, $count = 20)
	{
		$start = max(0, (int)$start);
		$count = max(20, (int)$count);
		$sql = "select * from " . $this->table . " order by id desc limit " . $start . "," .$count;
		return $this->db->getAll($sql, array());
	}
	
	public function getInfoById($id)
	{
		if (empty($id))return false;
		$info = $this->select(array('id'=>$id));
		if (!empty($info)){
			return $info[0];
		}
		return false;
	}
	
	public function getInfoByName($name) {
		if (empty($name)) return false;
		$info = $this->select(array('name'=>$name));
		if (!empty($info)) {
			return $info[0];
		}
		return false;
	}
}
?>